<?php

namespace App\HttpController\Web;

use App\HttpController\BaseController;
use App\Model\VideosModel;

class VideoController extends BaseController {

    public function index (){
        $request = $this->request();
        $page = $request->getRequestParam('page') ?: 1;
        $params = [
            'chanel_id' => $request->getRequestParam('chanel_id') ?: 0,//频道
            'option' => $request->getRequestParam('option') ?: 1,//推荐
        ];
        $model = new VideosModel();
        $lists = $model->select('id,title,thumb')
//            ->where(function($query) use($params){
//                if ($params['chanel_id']){
//                    $query->where('chanel_id',$params['chanel_id']);
//                }
//                if ($params['option']){
//                    $query->where('option',1);
//                }
//            })
            ->orderBy('sort')
            ->paginate($page,8);
        return $this->writeJson(0,$lists);
    }

}
